import { defHttp } from '@/utils/http/axios';
import {
  IDictCategoryListResult,
  IDictCategorySaveData,
  IDictDataListResult,
  IDictDataSaveData,
  ITypeListResult,
  ITypeSaveData,
} from './type';

enum Api {
  list = '/system/dict/type/list',
  typeSave = '/system/dict/type/save',
  typeUpdate = '/system/dict/type/update',
  typeRemove = '/system/dict/type/remove',

  dictDataList = '/system/dict/data/list',
  dictDataSave = '/system/dict/data/save',
  dictDataUpdate = '/system/dict/data/update',
  dictDataRemove = '/system/dict/data/remove',

  dictCategoryList = '/system/sys-dict-category/list',
  dictCategorySave = '/system/sys-dict-category/save',
  dictCategoryUpdate = '/system/sys-dict-category/update',
  dictCategoryRemove = '/system/sys-dict-category/remove',
}

/**
 * @description 列表
 * @date
 * @export
 * @param
 */
export function List(params) {
  return defHttp.get<ITypeListResult[]>({
    url: Api.list,
    params,
  });
}

/**
 * @description 新增字典
 * @date
 * @export
 * @param
 */
export function TypeSave(data: ITypeSaveData) {
  return defHttp.post({
    url: Api.typeSave,
    data,
  });
}

/**
 * @description 编辑字典
 * @date
 * @export
 * @param
 */
export function TypeUpdate(data: ITypeSaveData) {
  return defHttp.post({
    url: Api.typeUpdate,
    data,
  });
}

/**
 * @description 删除字典
 * @date
 * @export
 * @param
 */
export function TypeRemove(ids) {
  return defHttp.post({
    url: Api.typeRemove + `?ids=${ids}`,
  });
}

/**
 * @description 字典数据列表
 * @date
 * @export
 * @param
 */
export function DictDataList(params) {
  return defHttp.get<IDictDataListResult[]>({
    url: Api.dictDataList,
    params,
  });
}

/**
 * @description 字典数据新增
 * @date
 * @export
 * @param
 */
export function DictDataSave(data: IDictDataSaveData) {
  return defHttp.post({
    url: Api.dictDataSave,
    data,
  });
}

/**
 * @description 字典数据修改
 * @date
 * @export
 * @param
 */
export function DictDataUpdate(data: IDictDataSaveData) {
  return defHttp.post({
    url: Api.dictDataUpdate,
    data,
  });
}

/**
 * @description 删除字典数据
 * @date
 * @export
 * @param
 */
export function DictDataRemove(ids) {
  return defHttp.post({
    url: Api.dictDataRemove + `?ids=${ids}`,
  });
}

/**
 * @description 字典分类列表
 * @date
 * @export
 * @param
 */
export function DictCategoryList(params) {
  return defHttp.get<IDictCategoryListResult[]>({
    url: Api.dictCategoryList,
    params,
  });
}

/**
 * @description 字典分类新增
 * @date
 * @export
 * @param
 */
export function DictCategorySave(data: IDictCategorySaveData) {
  return defHttp.post({
    url: Api.dictCategorySave,
    data,
  });
}

/**
 * @description 字典分类修改
 * @date
 * @export
 * @param
 */
export function DictCategoryUpdate(data: IDictCategorySaveData) {
  return defHttp.post({
    url: Api.dictCategoryUpdate,
    data,
  });
}

/**
 * @description 删除字典分类
 * @date
 * @export
 * @param
 */
export function DictCategoryRemove(ids) {
  return defHttp.post({
    url: Api.dictCategoryRemove + `?ids=${ids}`,
  });
}
